package com.zycfc.zsf.boot.util.text;

import java.util.*;
import java.lang.reflect.*;

public class CheckUtil
{
    private static final String NOT_NULL = "\u4e0d\u80fd\u4e3a\u7a7a\uff01";
    private static final String CHECK_NOT_SUPPORT = "\u4e0d\u652f\u6301\u5165\u53c2\u7c7b\u578b\u7684\u6821\u9a8c\uff01";
    
    public static boolean isNull(final Object obj) {
        return obj == null;
    }
    
    public static boolean isNotNull(final Object obj) {
        return obj != null;
    }
    
    public static void notNull(final Object obj, final String message) {
        if (isNull(obj)) {
            throw new IllegalArgumentException(message + "\u4e0d\u80fd\u4e3a\u7a7a\uff01");
        }
    }
    
    public static boolean isEmpty(final Object obj) {
        return obj == null || (obj instanceof String && obj.toString().trim().length() == 0) || (obj instanceof Collection && ((Collection)obj).isEmpty()) || (obj instanceof Map && ((Map)obj).isEmpty()) || (obj.getClass().isArray() && Array.getLength(obj) == 0);
    }
    
    public static void notEmpty(final Object obj, final String message) {
        if (isEmpty(obj)) {
            throw new IllegalArgumentException(message + "\u4e0d\u80fd\u4e3a\u7a7a\uff01");
        }
    }
    
    public static boolean isNotEmpty(final Object obj) {
        return !isEmpty(obj);
    }
}
